<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateWxtjInterface extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        //接口分析数据
        Schema::create('wxtj_interface_summarys', function (Blueprint $table) {
            $table->increments('id')->comment('自增ID');
            $table->date('ref_date')->comment('数据的日期');
            $table->unsignedInteger('callback_count')->default(0)->comment('通过服务器配置地址获得消息后，被动回复用户消息的次数');
            $table->unsignedInteger('fail_count')->default(0)->comment('上述动作的失败次数');
            $table->unsignedInteger('total_time_cost')->default(0)->comment('总耗时，除以callback_count即为平均耗时');
            $table->unsignedInteger('max_time_cost')->default(0)->comment('最大耗时');
            $table->timestamps();
            $table->index(['ref_date'], 'index1');
        });
        //接口分析分时数据
        Schema::create('wxtj_interface_summaryhours', function (Blueprint $table) {
            $table->increments('id')->comment('自增ID');
            $table->date('ref_date')->comment('数据的日期');
            $table->string('ref_hour', 10)->default('')->comment('数据的小时');
            $table->unsignedInteger('callback_count')->default(0)->comment('通过服务器配置地址获得消息后，被动回复用户消息的次数');
            $table->unsignedInteger('fail_count')->default(0)->comment('上述动作的失败次数');
            $table->unsignedInteger('total_time_cost')->default(0)->comment('总耗时，除以callback_count即为平均耗时');
            $table->unsignedInteger('max_time_cost')->default(0)->comment('最大耗时');
            $table->timestamps();
            $table->index(['ref_date','ref_hour'], 'index1');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('wxtj_interface_summarys');
        Schema::dropIfExists('wxtj_interface_summaryhours');
    }
}
